<template>
	<view class="myRank padding">
		<view class="cu-list menu-avatar" style="margin-top: 360rpx;">
			<view class="cu-item">
				<view class="myRank_logo" style="position: absolute;left: 36rpx;font-size: 46rpx">
					<text class="cuIcon-crownfill text-yellow"></text>
				</view>
				<view class="cu-avatar round lg" style="position: absolute;left: 112rpx;">
					<image :src="myRankList1[0].image_url" mode="" style="width: 100rpx;height: 100rpx;border-radius: 50%;"></image>
				</view>
				<view class="content" style="left: 226rpx;">
					<view class="text-grey">
						<view class="text-cut">{{myRankList1[0].nickname}}</view>
					</view>
				</view>
				<view class="action" style="width: 140rpx;">
					<text class="bg-green text-xs" style="padding: 12rpx;border-radius: 18rpx;">积分：{{myRankList1[0].integral}}</text>
				</view>
			</view>
			<view class="cu-item">
				<view class="myRank_logo" style="position: absolute;left: 36rpx;font-size: 46rpx">
					<text class="cuIcon-crownfill" style="color: #C0C0C0;"></text>
				</view>
				<view class="cu-avatar round lg" style="position: absolute;left: 112rpx;">
					<image :src="myRankList1[1].image_url" mode="" style="width: 100rpx;height: 100rpx;border-radius: 50%;"></image>
				</view>
				<view class="content" style="left: 226rpx;">
					<view class="text-grey">
						<view class="text-cut">{{myRankList1[1].nickname}}</view>
					</view>
				</view>
				<view class="action" style="width: 140rpx;">
					<text class="bg-green text-xs" style="padding: 12rpx;border-radius: 18rpx;">积分：{{myRankList1[1].integral}}</text>
				</view>
			</view>
			<view class="cu-item margin-bottom">
				<view class="myRank_logo" style="position: absolute;left: 36rpx;font-size: 46rpx">
					<text class="cuIcon-crownfill" style="color: #A67D3D;"></text>
				</view>
				<view class="cu-avatar round lg" style="position: absolute;left: 112rpx;">
					<image :src="myRankList1[2].image_url" mode="" style="width: 100rpx;height: 100rpx;border-radius: 50%;"></image>
				</view>
				<view class="content" style="left: 226rpx;">
					<view class="text-grey">
						<view class="text-cut">{{myRankList1[2].nickname}}</view>
					</view>
				</view>
				<view class="action" style="width: 140rpx;">
					<text class="bg-green text-xs" style="padding: 12rpx;border-radius: 18rpx;">积分：{{myRankList1[2].integral}}</text>
				</view>
			</view>
			<!-- rest -->
			<view class="cu-item" v-for="(item,index) in myRankList2" :key="item+index">
				<view class="myRank_logo" style="position: absolute;left: 36rpx;font-size: 46rpx">
					<text class="text-grey">{{index+4}}</text>
				</view>
				<view class="cu-avatar round lg" style="position: absolute;left: 112rpx;">
					<image :src="item.image_url" mode="" style="width: 100rpx;height: 100rpx;border-radius: 50%;"></image>
				</view>
				<view class="content" style="left: 226rpx;">
					<view class="text-grey">
						<view class="text-cut">{{item.nickname}}</view>
					</view>
				</view>
				<view class="action" style="width: 140rpx;">
					<text class="bg-green text-xs" style="padding: 12rpx;border-radius: 18rpx;">积分：{{item.integral}}</text>
				</view>
			</view>
			<view v-if="isover" class="b_bottom text-center padding-top" style="padding-bottom: 20rpx;color: white;">
				----已经到底了-----
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data() {
			return {
				myRankList1:[],
				myRankList2:[],
				page:1,
				total:0,
				isover:false
			}
		},
		onLoad() {
			this.getMyRankData()
			this.getMyRankAllData()
		},
		methods:{
			async getMyRankAllData(){
				let res = await this.$myRuquest({
					url:`/other_ranking/?page=${this.page}`
				})
				this.total = res.data.count
				this.myRankList2 = [...this.myRankList2,...res.data.results]
			},
			async getMyRankData(){
				let res = await this.$myRuquest({
					url:'/ranking/'
				})
				this.myRankList1 = res.data.results
			},
			onReachBottom() {
				if(this.myRankList2.length>=this.total) return this.isover = true
				this.page++
				this.getMyRankAllData()
			},
		}
	}
</script>

<style lang="scss">
	.myRank{
		background: url(../../static/img/rank_bg1.jpg) no-repeat;
		background-size: 100% 100%;
	}
</style>
